#ifndef LOGUPLOAD_H
#define LOGUPLOAD_H

#include <QMainWindow>
#include <QObject>
#include <QWidget>
#include <QTcpServer>
#include <QTcpSocket>
#include <QFile>
#include <QMessageBox>

class MainWindow;

class LogUpload :public QObject {
    Q_OBJECT
public:
    LogUpload();
    ~LogUpload();
    static std::unique_ptr<LogUpload>& getInstance();
    void LogRequest(); // 发送日志请求

private:
    static std::unique_ptr<LogUpload>             LogUploadInstance;
    QTcpServer *server10001 = NULL; // 监听10001端口的服务器对象
    QTcpServer *server10002 = NULL; // 监听10002端口的服务器对象
    QTcpSocket *socket10001 = NULL;
    QTcpSocket *socket10002 = NULL;

    void handleConnection10001(); // 处理10001端口的新连接
    void handleConnection10002(); // 处理10002端口的新连接
    void readDataPort10001();     // 读取10001端口的数据
    void readDataPort10002();     // 读取10002端口的数据

    bool LogRequestFlag = false; // 日志请求标志位
    QByteArray buffer;
};

#endif // LOGUPLOAD_H
